#define _CRT_SECURE_NO_WARNINGS  1
#include<stdio.h>
int arr[10000][4];
int main()
{
    int a, b, g, k, n;
    scanf("%d", &n);
    int flag = -1;
    int i = 0;
    for (i = 0; i < n; i++)
    {
        scanf("%d%d%d%d", &a, &b, &g, &k);
        arr[i][0] = a;
        arr[i][1] = b;
        arr[i][2] = g;
        arr[i][3] = k;
    }
    int x, y;
    scanf("%d%d", &x, &y);
    i--;
    for (i; i >= 0; i--)
    {
        if (x >= arr[i][0] && x <= (arr[i][0] + arr[i][2]))
        {
            if (y >= arr[i][1] && y <= (arr[i][1] + arr[i][3]))
            {
                flag = i;
                break;
            }
        }
    }
    if (flag == -1)
        printf("-1");
    else
        printf("%d", flag + 1);
    return 0;
}